package com.right.health.app.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.magic.basic.utils.TimeUtil;
import com.right.health.app.constants.AppConfig;

/*
 * Created by hopeliao on 2019-11-23
 *
 */
public class DrugReminderInfo implements Parcelable {
    public String remindname;
    public String starttime;
    public String endtime;
    public int cycle; //服药周期
    public String cycletimes; //提醒时间
    public String netCycleTimes;
    public String remindtype;
    public String remindstatus;  // 是否开启提醒（0：关闭；1：开启）,
    public String iseat; //（0:未服用，1:已服用）,



    public String remindid;

    public String cycletimesid;
    public String time;
    public String times;

    private String showTime;
    public String getShowTime() {
        try {
            if(TextUtils.isEmpty(showTime)) {
                StringBuilder sb = new StringBuilder();
                String startTime = TimeUtil.convertTime(AppConfig.FORMAT_TIME, Long.parseLong(starttime));
                String endTime = TimeUtil.convertTime(AppConfig.FORMAT_TIME, Long.parseLong(endtime));

                sb.append(startTime).append(" ~ ").append(endTime);
                showTime = sb.toString();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return showTime;
    }

    public String getStartTime() {
        return TimeUtil.convertTime(AppConfig.FORMAT_TIME, Long.parseLong(starttime));
    }

    public String getEndTime() {
        return TimeUtil.convertTime(AppConfig.FORMAT_TIME, Long.parseLong(endtime));
    }

    public DrugReminderInfo() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.remindname);
        dest.writeString(this.starttime);
        dest.writeString(this.endtime);
        dest.writeInt(this.cycle);
        dest.writeString(this.cycletimes);
        dest.writeString(this.netCycleTimes);
        dest.writeString(this.remindtype);
        dest.writeString(this.remindstatus);
        dest.writeString(this.iseat);
        dest.writeString(this.remindid);
        dest.writeString(this.cycletimesid);
        dest.writeString(this.time);
        dest.writeString(this.times);
        dest.writeString(this.showTime);
    }

    protected DrugReminderInfo(Parcel in) {
        this.remindname = in.readString();
        this.starttime = in.readString();
        this.endtime = in.readString();
        this.cycle = in.readInt();
        this.cycletimes = in.readString();
        this.netCycleTimes = in.readString();
        this.remindtype = in.readString();
        this.remindstatus = in.readString();
        this.iseat = in.readString();
        this.remindid = in.readString();
        this.cycletimesid = in.readString();
        this.time = in.readString();
        this.times = in.readString();
        this.showTime = in.readString();
    }

    public static final Creator<DrugReminderInfo> CREATOR = new Creator<DrugReminderInfo>() {
        @Override
        public DrugReminderInfo createFromParcel(Parcel source) {
            return new DrugReminderInfo(source);
        }

        @Override
        public DrugReminderInfo[] newArray(int size) {
            return new DrugReminderInfo[size];
        }
    };
}
